{extend name="base" /} {block name="body"}
<div class="layui-body">
	<!--tab标签-->
	<div class="layui-tab layui-tab-brief">
		<ul class="layui-tab-title">
			<li class="">
				<a href="{:url('advertise/index')}">广告管理</a>
			</li>
			<li class="layui-this">添加广告</li>
		</ul>
		<div class="layui-tab-content">
			<div class="layui-tab-item layui-show">
				<form class="layui-form form-container" action="{:url('advertise/save')}" method="post">
					<div class="layui-form-item">
						<label class="layui-form-label">广告标题</label>
						<div class="layui-input-block">
							<input type="text" name="title" required lay-verify="required" placeholder="请输入广告标题" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
					<label class="layui-form-label">广告图</label>
					<div class="layui-input-block" style="padding-left: 10px;">
						<div class="layui-upload">
							<button type="button" class="layui-btn" id="image">上传图片</button>
							<div class="layui-upload-list">
								<img class="layui-upload-img" style="width: 150px;height: 150px;" id="demo1">
								<p id="demoText"></p>
							</div>
						</div>
					</div>
					<input type="hidden" name="thumb" id="thumb"/>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">链接地址</label>
						<div class="layui-input-block">
							<input type="tel" name="url" value="{$url}" autocomplete="off" placeholder="请输入链接地址" class="layui-input">
						</div>
					</div>
					<div class="layui-form-item" >
						<label class="layui-form-label">内容</label>
						<div class="layui-input-block">
							<script style="width:960px;height:600px" id="content" name="content" type="text/plain">

							</script>
						</div>
					</div>
					<div class="layui-form-item">
						<div class="layui-input-block">
							<button class="layui-btn" lay-submit lay-filter="*">添加</button>
							<button type="reset" class="layui-btn layui-btn-primary">重置</button>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
{/block}
{block name="js"}
<script type="text/javascript" src="/public/static/js/image.zip.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/public/ueditor/ueditor.all.js"></script>

<script>
	var ue = UE.getEditor('content', {
        initialFrameHeight: 450,
		serverUrl: "{:url('admin/ueditor/index?cate=news')}"
	});
	var GV = {
		current_controller: "advertise/index"
	};
	layui.use('upload', function() {
		var upload = layui.upload,
		jq = layui.jquery;
		upload.render({
			url: '{:url("upload")}',
			elem: '#image',
			ext: 'jpg|png|gif',
			area: ['500', '500px'],
			before: function(input) {
				
			},
			done: function(res) {
				if(res.code==1){
					$("#demo1").attr('src',res.src);
					$("#thumb").val(res.src);
				}
			}
		});
	})
</script>
{/block}